<!DOCTYPE html>
<html lang="en">
<head>
    <#include "/WEB-INF/views/common/meta.html" />
    <title>设备监控</title>
    <#include "/WEB-INF/views/common/css.html"/>
    <link rel="stylesheet" type="text/css" href="/static/lib/mui/css/mui.picker.min.css"/>
</head>
<body>
<header class="mui-bar mui-bar-nav bg-blue">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">${deviceCode}</h1>
</header>
<div class="mui-content">
    <div class="mui-content-padded">
        <form id="dataForm" action="/device/weldList" method="post">
            <input type="hidden" name="deviceCode" value="${deviceCode}">
            <input type="hidden" name="startTime" value="${startTime}">
            <input type="hidden" name="endTime" value="${endTime}">

            <button id="startTime" data-options='{"value":"${startTime}","beginYear":2010,"endYear":2020}' class="btn mui-btn mui-btn-block">${startTime}</button>
            <button id="endTime" data-options='{"value":"${endTime}","beginYear":2010,"endYear":2020}' class="btn mui-btn mui-btn-block">${endTime}</button>
            <div class="mui-button-row">
                <button type="button" class="mui-btn mui-btn-primary" onclick="commit()">焊接记录查询</button>
            </div>
        </form>
    </div>

</div>
</body>
<#include "/WEB-INF/views/common/js.html"/>
<script type="text/javascript" src="/static/lib/mui/js/mui.picker.min.js" ></script>
<script type="text/javascript">

    function commit(){
        var dataJson = $("#dataForm").serializeArray();
        console.log(JSON.stringify(dataJson));
        $.post("/device/ajaxWeldList",dataJson,function(result){
            if (result.success) {
                $("#dataForm").submit();
            }else{
                alert(result.message);
            }
        },"json");
    }


    (function($) {
        $.init();
        var btns = $('.btn');
        btns.each(function(i, btn) {
            btn.addEventListener('tap', function() {
                var obj = $(this);
                var optionsJson = this.getAttribute('data-options') || '{}';
                var options = JSON.parse(optionsJson);
                var id = this.getAttribute('id');
                var picker = new $.DtPicker(options);
                picker.show(function(rs) {
                    jQuery("#"+id).html(rs.text);
                    jQuery("input[name=" + id + "]").val(rs.text);
                    picker.dispose();
                });
            }, false);
        });
    })(mui);


</script>
</html>